{extend name='public/content'}

{block name="title"}
	注册
{/block}

{block name="body"}
	//测试验证码统一输 123456
	<form action="{:url('outlo/register')}" method="post">
		手机:<input type="text" name="mobile">
		<br>
		验证码
		<input type="text" name="cord" value=""><span class="huqyazhengma layui-btn layui-btn-normal">获取验证码</span>
		<br>
		<input type="hidden" name="yingcang">
		密码:<input type="password" name="password">
		<span class="layui-btn layui-btn-normal submitten">提交</span>
	</form>
	<a href="{:url('index/user/savepassword')}">修改密码</a>
	<a href="{:url('user/addreslist')}">地址列表</a>
{/block}
{block name="script"}
 	<script type="text/javascript">
 		require(['jquery'], function () {
 			$('.huqyazhengma').click(function() {
 				var mobile = $('input[name=mobile]').val();
 				$.ajax({
 					url: '{:url("outlo/getcord")}',
 					type: 'GET',
 					dataType: 'json',
 					data: {mobile:mobile},
 				})
 				.done(function(data) {
 					if(data.code==0){
 						alert("发送失败");
 					}
 					if(data.code==1){
 						alert("发送成功");
 					}

 				})
 				.fail(function() {
 					console.log("error");
 				})
 				.always(function() {
 					console.log("complete");
 				});
 			});
 			//验证，输入框变化就验证
			$('input[name=cord')[0].onchange=function(){
				var mobile = $('input[name=mobile]').val();
				var cord  = $('input[name=cord').val();
				$.ajax({
					url: '{:url("outlo/cordvertiy")}',
					type: 'GET',
					dataType: 'json',
					data: {mobile: mobile,cord:cord},
				})
				.done(function(data) {
					if(data==1){
						$('input[name=yingcang]').val(1)
						alert("验证码正确");
					}else{
						$('input[name=yingcang]').val(0)
						alert("验证码错误");
					}
				})
				.fail(function() {
					console.log("error");
				})
				.always(function() {
					console.log("complete");
				});	
			}

			//提交
			$('.submitten').click(function() {
				var yingcang = $('input[name=yingcang]').val();

				if(yingcang==1){
					$('form').submit();
				}else{
					alert("验证码还没通过");
				}
			});
 		})
 			
 	</script>
{/block}

{block name="style"}
 <style type="text/css">
 	
 </style>
{/block}